var kolom;
var typedata;

switch(type_window){
	case 'dealer':
	case 'dealer_transfer':
		kolom = [
			{field:'nama_dealer',title:'Nama Dealer',width:250, halign:'center', align:'left'},
		];
		typedata = 'searchdealer';
	break;
	case 'mutasi':
		kolom = [
			{field:'no_mutasi_barang',title:'No. Mutasi',width:200, halign:'center', align:'left'},
			{field:'nama_dealer',title:'Dealer',width:200, halign:'center', align:'left'},			
		];
		typedata = 'searchmutasi';		
	break;
	case 'penerima':
	case 'pengecek':
	case 'pengirim':
		kolom = [
			{field:'nama_karyawan',title:'Nama Karyawan',width:250, halign:'center', align:'left'},
		];
		typedata = 'searchkaryawan';
	break;
	case 'barang':
		kolom = [
			{field:'nama_barang',title:'Nama Barang', width:250, halign:'center', align:'left'},
		];
		typedata = 'searchbarang';
	break;
	case 'gudang':
		kolom = [
			{field:'nama_gudang',title:'Nama Gudang', width:250, halign:'center', align:'left'},
		];
		typedata = 'searchgudang';
	break;
	case 'barang_bawah':
		kolom = [
			{field:'nama_barang',title:'Nama Barang', width:250, halign:'center', align:'left'},
		];
		typedata = 'searchbarang';
	break;
}

$("#table_search_"+type_window).datagrid({     
	height:frmHeight-400,
	width:frmWidth-600,
	rownumbers:true,
	fit:true,
	striped:true,
	pagination:true,
	sortable:true,
	url:'supply/getdata/'+typedata+'/',		
	nowrap: false,
	singleSelect:true,
	pageNumber:'1',
	columns:[kolom],
	queryParams:{
		parameter_data: type_getdisp
	},
	onClickRow: function(rowIndex, rowData){
		if(type_window == 'dealer'){
			$('#dealer_'+type_getdisp).val(rowData.nama_dealer);
			$('#id_dealer_'+type_getdisp).val(rowData.id);
		}else if(type_window == 'dealer_transfer'){
			$('#dealer_transfer_'+type_getdisp).val(rowData.nama_dealer);
			$('#id_dealer_transfer_'+type_getdisp).val(rowData.id);
		}else if(type_window == 'mutasi'){
			$('#mutasi_'+type_getdisp).val(rowData.no_mutasi_barang);
			$('#id_mutasi_'+type_getdisp).val(rowData.id);
			$('#tgl_mutasi_brg_'+type_getdisp).html(rowData.tgl_mutasi);
			$('#pngrim_brg_'+type_getdisp).html(rowData.nama_karyawan);
		}else if(type_window == 'penerima'){
			$('#penerima_'+type_getdisp).val(rowData.nama_karyawan);
			$('#id_penerima_'+type_getdisp).val(rowData.id);
		}else if(type_window == 'pengecek'){
			$('#pengecek_'+type_getdisp).val(rowData.nama_karyawan);
			$('#id_pengecek_'+type_getdisp).val(rowData.id);
		}else if(type_window == 'pengirim'){
			$('#pengirim_'+type_getdisp).val(rowData.nama_karyawan);
			$('#id_pengirim_'+type_getdisp).val(rowData.id);
		}else if(type_window == 'barang'){
			$('#barang_'+type_getdisp).val(rowData.nama_barang);
			$('#id_barang_'+type_getdisp).val(rowData.id);
		}else if(type_window == 'gudang'){
			$('#gudang_'+type_getdisp).val(rowData.nama_gudang);
			$('#id_gudang_'+type_getdisp).val(rowData.id);
		}else if(type_window == 'barang_bawah'){
			$('#dtbarang_'+type_getdisp+'_'+nomer_id).val(rowData.nama_barang);
			$('#id_barang_'+type_getdisp+'_'+nomer_id).val(rowData.id);
		}
		closeWindow2();
	}
});
